Import("utils.js")


isBlueMode()
Import("ggUtils.js")

Import("B抖音极速版.js")
// SystemPrint.log('初始化-开始')


var currentAppPackName = ''

function initbaseetting() {
    // 

    
    // 

    sleep.second(1)
    clearData()
    print.log('脚本启动中, 请稍等...')


    if (!uiSwitch.findByID(控件ID = "envmode").getOn()) {
        setENVConfig('ENV', 'test')
        SystemPrint.log('启用调试模式: ' + ENV())
    } else {
        setENVConfig('ENV', 'pro')
    }


    if (!agent.isOpen()) {
        print.log('启用HID模式')
        SystemPrint.log('启用HID 模式' + hid.isOn())
    } else {

        // hid.s()
        SystemPrint.log('启用agent 模式')
        agent.start()
        seting.setAgentScreenShotModel(true)
        agent.shell('dumpsys battery set status 1')
        // agent.shell('dumpsys battery set status 2')
    }


    print.log('判断截屏权限')
    requestScreen权限()

    sleep.millisecond(500)
}

var threadZB = new thread();
function startZB_thread(onInit, onStep) {
    threadZB.runJsCode(() => {
        onInit()

        whilestep((steptimes) => {
            onStep(steptimes)
        }, (60) * 60, 5)
    }, "直播线程")
}


initbaseetting()

var isuccess直播开宝箱 = true
start_直播养号_DYJSB(null, (isSuccess) => {
    isuccess直播开宝箱 = isSuccess
})
startZB_thread(
    () => {
        go看直播挂机()
    }, (steptimes) => {
        if (steptimes % 12 == 0) {
            agentOrHidClick(ocrText('点击进入', '直播间'))
        }
    }
)

if (isuccess直播开宝箱) {
    sleep.second((isEnableSwitch('is_more_zb') ? 60 : 50) * 60)
}
if (threadZB && threadZB.isAlive()) {
    threadZB.stop()
    // agentOrHidClick(backUntilFindView(() => {
    //     return ocrText('坚持', '放弃', '退出')
    // }, 4, 2))
    // sleep.second(3)
    // agentOrHidClick(ocrText('评价并收下', '评价', '开心收下', '收下金币'))
    stopAllApp()
}

var isuccess直播红包雨看 = true
start_直播红包雨看_DYJSB(() => {
    isuccess直播红包雨看 = false
})
startZB_thread(
    () => {
        go看直播挂机()
    }, (steptimes) => {
        if (steptimes % 12 == 0) {
            agentOrHidClick(ocrText('点击进入', '直播间'))
        }
    }
)

if (isuccess直播红包雨看) {
    sleep.second((isEnableSwitch('is_more_zb') ? 60 : 30) * 60)
}


if (threadZB && threadZB.isAlive()) {
    threadZB.stop()
    // agentOrHidClick(backUntilFindView(() => {
    //     return ocrText('坚持', '放弃', '退出')
    // }, 4, 2))
    // sleep.second(5)
    stopAllApp()
}


start_直播红包雨_DYJSB()
startZB_thread(
    () => {
        go看直播挂机()
    }, (steptimes) => {
        if (steptimes % 12 == 0) {
            agentOrHidClick(ocrText('点击进入', '直播间'))
        }
    }
)

sleep.second((isEnableSwitch('is_more_zb') ? 60 : 40) * 60)

if (threadZB && threadZB.isAlive()) {
    threadZB.stop()
    // agentOrHidClick(backUntilFindView(() => {
    //     return ocrText('坚持', '放弃', '退出')
    // }, 4, 2))
    // sleep.second(5)
    stopAllApp()
}

start_养双红包雨_DYJSB()

